package com.itrencai.arraylist;

import java.util.ArrayList;

public class Demo2cunchuzidingyileixing {
    //存储自定义类型
    //影院系统需要在后台上存储三部电影，然后依次展示出来
    public static void main(String[] args) {
        //1.定义一个电影类movie
        //2.定义一个ArrayList影片集合存储影片对象
        ArrayList<Movie> movies=new ArrayList<>();
        //3.创建影片对象封装电影数据，把对象加入到集合中去
        Movie m1=new Movie("《肖申克的救赎》",9.7,"罗宾斯");
        movies.add(m1);
        Movie m2=new Movie("《霸王别姬》",9.6,"张国荣，张丰毅");
        movies.add(m2);
        Movie m3=new Movie("《阿甘正传》",9.5,"汤姆，汉克斯");
        movies.add(m3);

        //4.遍历集合中的影片对象并展示出来
        for (int i = 0; i < movies.size(); i++) {
            Movie movie=movies.get(i);
            System.out.println("片名："+movie.getName());
            System.out.println("评分："+movie.getScore());
            System.out.println("主演："+movie.getActor());

        }

    }
}
